package com.company.工厂模式;

import com.company.工厂模式.impl.Apple;
import com.company.工厂模式.impl.Peach;
import com.company.工厂模式.impl.Pear;

/**
 * 水果工厂生产水果
 */
public class FruitFactory {
    FruitFactory() {
    }

    private final  static int TYPE_A = 1;
    private final  static int TYPE_PC = 2;
    private final  static int TYPE_PR = 3;

    public Fruit createFruit(int type){
        switch (type){
            case TYPE_A:
                return new Apple();
            case TYPE_PC:
                return new Peach();
            case TYPE_PR:
                return new Pear();
            default:
                throw new RuntimeException("本工厂还暂未生产您所需要的水果！");
        }
    }
}
